package com.imageflowpro.image_flow_pro.controller.user;


import com.imageflowpro.image_flow_pro.context.BaseContext;
import com.imageflowpro.image_flow_pro.dto.CreateOrderDTO;
import com.imageflowpro.image_flow_pro.dto.UserGetOrderListDTO;
import com.imageflowpro.image_flow_pro.result.Result;
import com.imageflowpro.image_flow_pro.service.IMediaOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("userOrderController")
@RequestMapping("/user/order")
//用户订单接口
public class OrderController {

    @Autowired
    private IMediaOrderService iMediaOrderService;

    @PostMapping("/createOrder")
    public Result userCreateOrder(@RequestBody CreateOrderDTO createOrderDTO){
        iMediaOrderService.userCreateOrder(createOrderDTO);
        return Result.success();
    }

    @GetMapping("/getOrderList")
    public Result<UserGetOrderListDTO> userGetOrderList(){
        return Result.success(iMediaOrderService.userGetOrderList(BaseContext.getCurrentId()));
    }

    @PutMapping("/updateSuperOrder/{orderId}/{state}")
    public Result updateSuperOrder(@PathVariable("orderId") Long orderId,@PathVariable("state") Boolean state){
        iMediaOrderService.updateSuperOrder(orderId,state);
        return Result.success();
    }

}
